<?php

namespace StarCloud\Library\Sdk;

use Framework\DiServices\HttpClient;
use Phalcon\Di;
use StarCloud\Library\HttpCurl;

class ProviderMcn
{
    use HttpCurl;

    /* @var $httpClient HttpClient */
    private $httpClient = null;

    public function __construct()
    {
        $this->httpClient = Di::getDefault()->get('httpClient');
        $this->cacheClass = Di::getDefault()->get('redis');
    }

    public function getHeader()
    {
        return [
            'Cookie' => 'tt_webid=7392034549394146854; s_v_web_id=verify_lynr6xxv_2c42f8ba_ed7d_870f_0f29_e20477800321; passport_csrf_token=230e293d02790db107d5a51b21ba7113; passport_csrf_token_default=230e293d02790db107d5a51b21ba7113; passport_auth_status=f2ffb392bb18299f9a26a46ee6810776%2C; passport_auth_status_ss=f2ffb392bb18299f9a26a46ee6810776%2C; uid_tt=3b9b821baa23deb5708b29fb23c7c5e4; uid_tt_ss=3b9b821baa23deb5708b29fb23c7c5e4; sid_tt=db4268a56a9b4a032e3eee56107c496d; sessionid=db4268a56a9b4a032e3eee56107c496d; sessionid_ss=db4268a56a9b4a032e3eee56107c496d; csrf_session_id=7e23f2582d563229836452f520b8610e; star_sessionid=db4268a56a9b4a032e3eee56107c496d; possess_scene_star_id=1803553434231012; x-jupiter-uuid=17220730045695024; gf_part_1785866=30; Hm_lvt_5d77c979053345c4bd8db63329f818ec=1721092181,1722073005; Hm_lpvt_5d77c979053345c4bd8db63329f818ec=1722073005; HMACCOUNT=F9D1FD5F014D616B; tt_scid=C4wr.3buv3aCKQQbIE58v-c6CI-5UBai40T73WTxjOqUoSR0AQdwhT5x0j52xI7aa0ab; sid_guard=db4268a56a9b4a032e3eee56107c496d%7C1722073077%7C5184000%7CWed%2C+25-Sep-2024+09%3A37%3A57+GMT; sid_ucp_v1=1.0.0-KDRhMjRlYWUwZTNjYmY4ZTdkYTg4ZTg2NjJmZjFlMmFiMzk1ZWJjYzcKFwjOvuC76PT1BxD1_5K1BhimDDgCQPEHGgJsZiIgZGI0MjY4YTU2YTliNGEwMzJlM2VlZTU2MTA3YzQ5NmQ; ssid_ucp_v1=1.0.0-KDRhMjRlYWUwZTNjYmY4ZTdkYTg4ZTg2NjJmZjFlMmFiMzk1ZWJjYzcKFwjOvuC76PT1BxD1_5K1BhimDDgCQPEHGgJsZiIgZGI0MjY4YTU2YTliNGEwMzJlM2VlZTU2MTA3YzQ5NmQ; csrftoken=DcB3eSm9-Zg3Xm9b85J-cURuZt0UaDltOZAQ'];
    }

    public function getTaskDetail($taskId)
    {
        $url = 'https://www.xingtu.cn/gw/api/task/provider_get_task_detail?';
        $body = [
            "task_id" => $taskId,
        ];
        $response = $this->httpClient->sendGetRequest($url . http_build_query($body), $body, $this->getHeader());


        $result = json_decode($response->getBody()->getContents(), true);

        if (isset($result['base_resp']['status_code']) && in_array($result['base_resp']['status_code'], [0])) {
            return $result['task_detail_info'];
        }

        return false;
    }
}